<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>wctomb</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_010_698">&nbsp;</a>NAME</h4><blockquote>
wctomb - convert a wide-character code to a character
</blockquote><h4><a name = "tag_000_010_699">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="stdlib.h.html">stdlib.h</a>&gt;

int wctomb(char *<i>s</i>, wchar_t <i>wchar</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_010_700">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>wctomb()</i>
function determines the number of bytes needed to represent the
character corresponding to the
wide-character code whose
value is
<i>wchar</i>
(including any change in the shift state).
It stores the character representation (possibly
multiple bytes and any special
bytes to change shift state) in the array
object pointed to by
<i>s</i>
(if
<i>s</i>
is not a null pointer).  At most {MB_CUR_MAX} bytes are stored.  If
<i>wchar</i>
is 0,
<i>wctomb()</i>
is left in the initial shift state.
<p>
The behaviour of this function is affected by the LC_CTYPE category
of the current locale.
For a state-dependent encoding, this function is placed into its
initial state by a call for which its character pointer argument,
<i>s</i>,
is a null pointer.
Subsequent calls with
<i>s</i>
as other than a null pointer cause the internal state of the function to be
altered as necessary.  A call with
<i>s</i>
as a null pointer causes this function to return a non-zero
value if encodings have state dependency, and 0 otherwise.
Changing the LC_CTYPE category causes the shift state of this
function to be indeterminate.
<p>
The implementation will behave as if no function defined in this document
calls
<i>wctomb()</i>.
</blockquote><h4><a name = "tag_000_010_701">&nbsp;</a>RETURN VALUE</h4><blockquote>
If
<i>s</i>
is a null pointer,
<i>wctomb()</i>
returns a non-zero or 0 value, if character encodings, respectively, do or
do not have state-dependent encodings.  If
<i>s</i>
is not a null pointer,
<i>wctomb()</i>
returns -1 if the value of
<i>wchar</i>
does not correspond to a valid character, or returns
the number of bytes that constitute the character
corresponding to the value of
<i>wchar</i>.
<p>
In no case will the value returned be greater than the value of
the MB_CUR_MAX macro.
</blockquote><h4><a name = "tag_000_010_702">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_000_010_703">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_704">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_705">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_706">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="mblen.html">mblen()</a></i>,
<i><a href="mbtowc.html">mbtowc()</a></i>,
<i><a href="mbstowcs.html">mbstowcs()</a></i>,
<i><a href="wcstombs.html">wcstombs()</a></i>,
<i><a href="stdlib.h.html">&lt;stdlib.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the ANSI C standard.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

